package com.md.livingstreamsound;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.launcher.ARouter;
import com.living.filedownloader.DownLoadManger;
import com.md.basedpc.application.BaseApplication;
import com.yxt.function_sdk_share.util.ShareUtil;

public class LivingApp extends BaseApplication {

    private boolean isDebug = true;//待改成根据flavor判断

    @Override
    public void onCreate() {
        super.onCreate();
        DownLoadManger.init(this);
        if (isDebug) {
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(this); // 尽可能早，推荐在Application中初始化
        /**
         * 分享初始化
         */
        ShareUtil.initShare(this);
//        ShareUtil.setWeixin();
//        ShareUtil.setQQZone();

        registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
            @Override
            public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
                Log.e("LivingApp", "onCreate=" + activity.toString());
            }

            @Override
            public void onActivityStarted(@NonNull Activity activity) {

            }

            @Override
            public void onActivityResumed(@NonNull Activity activity) {

            }

            @Override
            public void onActivityPaused(@NonNull Activity activity) {

            }

            @Override
            public void onActivityStopped(@NonNull Activity activity) {

            }

            @Override
            public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {

            }

            @Override
            public void onActivityDestroyed(@NonNull Activity activity) {

            }
        });


//        GlobalScope.launch {
//            try {
//                // Wait (suspend) for reult
//
//                val categories: List<Category> = RetrofitBuilder.apiService.getCategoriesList()
//                Log.d("ApiTest", "getCategories: $categories")
//
//                val dailyAlbums: List<Album> = RetrofitBuilder.apiService.getDailyAlbums()
//                Log.d("ApiTest", "getDailyAlbums: $dailyAlbums")
//
//                val category1: Category = RetrofitBuilder.apiService.getCategoryInfo(1)
//                // Now we can work with result object
//                Log.d("ApiTest", "getCategory: $category1")
//
//                val album1: Album = RetrofitBuilder.apiService.getAlbumInfo(1)
//                Log.d("ApiTest", "getAlbum: $album1")
//                val audio1: Audio = RetrofitBuilder.apiService.getAudioInfo(1)
//                Log.d("ApiTest", "getAudio: $audio1")
//
//            } catch (e: HttpException) {
//                // Catch http errors
//                Log.e("ApiTest", "exception${e.code()}", e)
//
//                println()
//            } catch (e: Throwable) {
//                Log.e("ApiTest", "exception", e)
//            }
//        }
    }


}
